<extend name="Public/base" />

<!-- 子導航 -->
<block name="sidebar">
    <include file="sidemenu" />
</block>

<block name="body">
	
	<div class="main-title cf">
                    <h2>委託篩選</h2>
	</div>
	<form id="form" action="{:U('Admin/Article/screening')}" method="post" class="form-horizontal">
                        <label class="item-label">區域<span class="check-tips">(請用英文逗號隔開，例如：拱北,澳門)</span></label>
                        <label class="textarea input-large">
                         <textarea name="area">{$data['area']}</textarea>
                         </label>
                        
                        <label class="item-label">面積<span class="check-tips">(請用英文逗號隔開，例如：50平方米,100平方米)</span></label>
                        <label class="textarea input-large">
                         <textarea name="widespread">{$data['widespread']}</textarea>
                         </label>
                        
                        <label class="item-label">類型<span class="check-tips">(請用英文逗號隔開，例如：豪宅,公寓)</span></label>
                        <label class="textarea input-large">
                         <textarea name="type">{$data['type']}</textarea>
                         </label>
                        
                        <label class="item-label">樓層<span class="check-tips">(請用英文逗號隔開，例如：第一層,第二層)</span></label>
                        <label class="textarea input-large">
                         <textarea name="floor">{$data['floor']}</textarea>
                         </label>
                        
                         <label class="item-label">價格<span class="check-tips">(請用英文逗號隔開，例如：100,200)</span></label>
                        <label class="textarea input-large">
                         <textarea name="price">{$data['price']}</textarea>
                         </label>
                        
                        <div class="form-item cf">
				<a class="btn btn-return" id="submit" target-form="form-horizontal">確 定</a>
			<a class="btn btn-return" href="{$Think.cookie.__forward__}">返 回</a>
			<if condition="C('OPEN_DRAFTBOX') and (ACTION_NAME eq 'add' or $data['status'] eq 3)">
			<button class="btn save-btn" url="{:U('article/autoSave')}" target-form="form-horizontal" id="autoSave">
				存草稿
			</button>
			</if>
			<input type="hidden" name="id" value="{$data.id|default=''}"/>
			<input type="hidden" name="pid" value="{$data.pid|default=''}"/>
			<input type="hidden" name="model_id" value="{$data.model_id|default=''}"/>
			<input type="hidden" name="category_id" value="{$data.category_id|default=''}">
		</div>


		
	</form>
	
</block>

<block name="script">
<link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
<php>if(C('COLOR_STYLE')=='blue_color') echo '<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php>
<link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script type="text/javascript">

Think.setValue("type", {$data.type|default='""'});
Think.setValue("display", {$data.display|default=0});



$(function(){
    $('.time').datetimepicker({
        format: 'yyyy-mm-dd hh:ii',
        language:"zh-CN",
        minView:2,
        autoclose:true
    });
    showTab();

	<if condition="C('OPEN_DRAFTBOX') and (ACTION_NAME eq 'add' or $data['status'] eq 3)">
	//保存草稿
	var interval;
	$('#autoSave').click(function(){
        var target_form = $(this).attr('target-form');
        var target = $(this).attr('url')
        var form = $('.'+target_form);
        var query = form.serialize();
        var that = this;

        $(that).addClass('disabled').attr('autocomplete','off').prop('disabled',true);
        $.post(target,query).success(function(data){
            if (data.status==1) {
                updateAlert(data.info ,'alert-success');
                $('input[name=id]').val(data.data.id);
            }else{
                updateAlert(data.info);
            }
            setTimeout(function(){
                $('#top-alert').find('button').click();
                $(that).removeClass('disabled').prop('disabled',false);
            },1500);
        })

        //重新開始定時器
        clearInterval(interval);
        autoSaveDraft();
        return false;
    });

	//Ctrl+S保存草稿
	$('body').keydown(function(e){
		if(e.ctrlKey && e.which == 83){
			$('#autoSave').click();
			return false;
		}
	});

	//每隔壹段時間保存草稿
	function autoSaveDraft(){
		interval = setInterval(function(){
			//只有基礎信息填寫了，才會觸發
			var title = $('input[name=title]').val();
			var name = $('input[name=name]').val();
			var des = $('textarea[name=description]').val();
			if(title != '' || name != '' || des != ''){
				$('#autoSave').click();
			}
		}, 1000*parseInt({:C('DRAFT_AOTOSAVE_INTERVAL')}));
	}
	autoSaveDraft();

	</if>

});
</script>
</block>
